package com.huakai.springenv.config;

import com.huakai.springenv.service.MyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnMissingBean(MyService.class)
@Slf4j
public class ServiceConfig implements BeanFactoryAware {

    @Bean
    public MyService myService() {
        return new MyService();
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        log.info("ServiceConfig setBeanFactory = {}",beanFactory.getClass());
    }
}
